<?php

class ApiarioColmena extends Maestra
{
	const COL_ID      		= 'ID_APICOL';
	const COL_COLMENA      	= 'ID_COLMENA';
	const COL_APIARIO      	= 'ID_APIARIO';
	const COL_ESTADO      	= 'ESTADO';
	
	
	const ESTADO_ACTIVO 		= '1';
	const ESTADO_INACTIVO 		= '0';


	const TBL_NAME = 'apiario_colmena';
	
	static public function getDatos($iID)
	{
		$oModel= self::getInstance();
		$sSql = "SELECT * FROM ".self::TBL_NAME;
		$sSql.= " WHERE ";
		$sSql.= self::COL_ID." = $iID";
		$arr = $oModel->dB->Execute($sSql);
		$oData = $arr->FetchObj();
		return $oData;
	}
		

	static public function getAll()
	{
		$oModel = self::getInstance();
		$sSql = "SELECT * FROM ".self::TBL_NAME;
		$arr = $oModel->dB->GetArray($sSql);
		return $arr;
	}	
	
	static public function insertar($aDatos)
	{
		$oCon = self::getInstance();
		if($oCon->dB->AutoExecute(self::TBL_NAME, $aDatos, 'INSERT'))
		{
			$lasId = $oCon->dB->Insert_ID();
		}else{
			$lasId = 0;
		}
		return $lasId;
	}

	static public function eliminar($aDatos, $id)
	{
		$oCon = self::getInstance();
		$iReturn = $oCon->dB->AutoExecute(self::TBL_NAME, $aDatos, 'UPDATE', self::COL_ID.'='.$id);
		return $iReturn;
	}

	static public function actualizar($aDatos, $id)
	{
		$oCon = self::getInstance();
		$iReturn = $oCon->dB->AutoExecute(self::TBL_NAME, $aDatos, 'UPDATE', self::COL_ID.'='.$id);
		return $iReturn;
	}
}

